import React, { Component } from "react";
import TabCnntrol from "./TabControl";


export default class App extends Component {
  constructor(props) {
    super(props)
    this.titles = ['新款', '精选', '流行']
    this.state = {
      currentTitle: '新款',
      currentIndex: 0
    }
  }
  render() {
    console.log(this.state.currentTitle);
    return (
      <div>
        <TabCnntrol titles={this.titles} itemClick={index => this.itemClick(index)} />
        <h2>{this.state.currentTitle}</h2>
      </div>
    )
  }
  itemClick(index) {
    this.setState({
      currentTitle: this.titles[index]
    })
  }
}